using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Secretaria_Buscar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            if (biFactory.User().IdPerfil == 0)
            {
                cboCursos.SourceData = "proc_CursoDisponibles ";
            }
            else
            {
                cboCursos.SourceData = "proc_CursoDisponibles " + biFactory.User().IdSede.ToString();
            }
            cboCursos.TipoOrigen = Controles_cboGeneric.TipoSource.Procedure;
            cboCursos.NameId = "IdCurso";
            cboCursos.NameDescript = "CursoDescrip";
            cboCursos.BindCBO();
            ShowGrid();
        }
        else
        {
            gvAlumnos.Visible = false;
            ShowGrid();
        }
      

    }
    protected void cmdBuscar_Click(object sender, EventArgs e)
    {
        ShowGrid();
    }

    private void ShowGrid()
    {
        if (cboCursos.Value !="-1")
        {
            if (biFactory.User().IdPerfil == 0)
            {
                gvAlumnos.DataSource = SchoolsBI.Materia.Tabla("proc_getAlumnosNotasFinales  " + cboCursos.Value);
            }
            else
            {
                gvAlumnos.DataSource = SchoolsBI.Materia.Tabla("proc_getAlumnosNotasFinales " + cboCursos.Value + "," + biFactory.User().IdSede.ToString());
            }
            gvAlumnos.DataBind();
            gvAlumnos.Visible = true;
        }
    }
    protected void cmdForzar_Click(object sender, EventArgs e)
    {
        if (cboCursos.Value != "-1")
        {
            if (biFactory.User().IdPerfil == 0)
            {
                gvAlumnos.DataSource = SchoolsBI.Materia.Tabla("proc_getAlumnosNotasFinales  " + cboCursos.Value + ", @forzar=1");
            }
            else
            {
                gvAlumnos.DataSource = SchoolsBI.Materia.Tabla("proc_getAlumnosNotasFinales " + cboCursos.Value + "," + biFactory.User().IdSede.ToString() +",1");
            }
            gvAlumnos.DataBind();
            gvAlumnos.Visible = true;
        }
    }
}
